﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ProjectCore.Application;
using ProjectCore.Application.AppUser.Dto;
using ProjectCore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ProjectCore.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UsersController : ControllerBase
    {
        private readonly IAppUsers appUsers;
        public UsersController(IAppUsers _appAdmin)
        {
            appUsers = _appAdmin;
        }
        /// <summary>
        /// 获取用户集合
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetUserIs(int pageIndex, int pageSize)
        {
            Task<HeaderResult<List<UserI>>> userIs = appUsers.GetUserIs(pageIndex,pageSize);
            return Ok(new { data = await userIs });
        }


        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> DelUserI(int Id)
        {
            Task<int> n = appUsers.DelUserI(Id);
            return Ok(new
            {
                data = await n
            });
        }
    }
}
